package StringBuffer;

/**
 * @Author admin
 * @Date 2019/3/27 10:21
 */
public class StringBufferTest {
    public static void main(String[] args) {
        System.out.println("1.添加---------------");
        StringBuffer sb1=new StringBuffer();
        sb1.append("abcdefg");
        System.out.println("append添加结果"+sb1);
        sb1.insert(2,"123");
        System.out.println("insert指定位置添加结果"+sb1);
        System.out.println("2.删除----------------");
        sb1.delete(1,8);
        System.out.println("delete删除指定位置结果"+sb1);
        sb1.deleteCharAt(2);
        System.out.println("deleteChatAt删除指定位置结束"+sb1);
        sb1.delete(0,sb1.length());
        System.out.println("清空缓冲区结果"+sb1);
        System.out.println("3.修改-----------------");
        StringBuffer sb2=new StringBuffer("abcdef");
        sb2.setCharAt(1,'p');
        System.out.println("setChartAt修改指定位置字符结果"+sb2);
        sb2.replace(0,1,"qq");
        System.out.println("replace替换指定位置字符（串）结果"+sb2);
        sb2.reverse();
        System.out.println("字符串翻转结果"+sb2);
    }
}
